package org.qiyu.live.api.controller;

import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.dubbo.config.annotation.DubboReference;
import org.qiyu.live.api.service.IUserLoginService;
import org.qiyu.live.common.interfaces.vo.WebResponseVO;
import org.qiyu.live.user.interfaces.IUserPhoneRPC;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @Params
 * @Return
 * @Description 用户控制器
 * @Author zhangguangyan
 * @Date 2023-08-25 22:46:38
 */

@RestController
@RequestMapping("/userLogin")
public class UserController {

    @Resource
    private IUserLoginService userLoginService;
    @DubboReference
    private IUserPhoneRPC userPhoneRPC;

    //发送验证码
    @PostMapping("/sendLoginCode")

    public WebResponseVO sendLoginCode(String phone) {
        return userLoginService.sendLoginCode(phone);
    }

    //登录请求 验证码是否合法 -> 初始化注册/老用户登录
    @PostMapping("/login")

    public WebResponseVO login(String phone, Integer code, HttpServletResponse response) {
        return userLoginService.login(phone,code,response);
    }
}
